package org.example.evaluate.enums;

import java.math.BigDecimal;
import java.util.stream.Stream;

public enum StartingUp {
    nomal(31, "开机正常(开机正常，无死机重启现象)", BigDecimal.valueOf(0.99)),
    warn(32, "开机不正常(开机不正常出现死机/重启/不开机)", BigDecimal.valueOf(80)),
    error(72, "无法正常开机使用(开机出现重启、死机、定屏、发烫、无法进入无法开机现象)", BigDecimal.valueOf(70)),
    fatal(73, "无法开机(开机无反应，连接电脑、充电器等外置USB接口无任何反应。)", BigDecimal.valueOf(68));

    private final Integer code;
    private final String name;
    private final BigDecimal kf;

    StartingUp(Integer code, String name, BigDecimal kf) {
        this.code = code;
        this.name = name;
        this.kf = kf;
    }

    public Integer getCode() {
        return code;
    }

    public BigDecimal getKf() {
        return kf;
    }

    public static StartingUp buildStartingUp(Integer code) {
        return Stream.of(StartingUp.values())
                .filter(v -> v.getCode() == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(String.format("传入的版本 [%s] 不正确", code)));
    }
}
